<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="utf-8">
  
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>vue2.0一起在懵逼的海洋里越陷越深（五） | leenty blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="前言本文章系列：vue2.0一起在懵逼的海洋里越陷越深 (http://leenty.com/tags/vuejs/)之前的几篇文章的说了vue-router以及vuex的简单使用，这次就开始组合这两者进行实际应用。场地呢就在我的vue2.0Demo,这是源码地址,觉得靠谱的话欢迎加星跟随,有问题欢迎评论和指正😃OK交代完毕，说下这回要完成的内容。这回要做的是一个带缩放功能的滑动菜单(就是一个侧">
<meta name="keywords" content="css,vuejs,vue-router,vuex">
<meta property="og:type" content="article">
<meta property="og:title" content="vue2.0一起在懵逼的海洋里越陷越深（五）">
<meta property="og:url" content="http://baidu.com/2016/12/11/vue2-5/index.html">
<meta property="og:site_name" content="leenty blog">
<meta property="og:description" content="前言本文章系列：vue2.0一起在懵逼的海洋里越陷越深 (http://leenty.com/tags/vuejs/)之前的几篇文章的说了vue-router以及vuex的简单使用，这次就开始组合这两者进行实际应用。场地呢就在我的vue2.0Demo,这是源码地址,觉得靠谱的话欢迎加星跟随,有问题欢迎评论和指正😃OK交代完毕，说下这回要完成的内容。这回要做的是一个带缩放功能的滑动菜单(就是一个侧">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://leenty.com/img/vue/shangche.jpg">
<meta property="og:updated_time" content="2016-12-12T13:56:58.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="vue2.0一起在懵逼的海洋里越陷越深（五）">
<meta name="twitter:description" content="前言本文章系列：vue2.0一起在懵逼的海洋里越陷越深 (http://leenty.com/tags/vuejs/)之前的几篇文章的说了vue-router以及vuex的简单使用，这次就开始组合这两者进行实际应用。场地呢就在我的vue2.0Demo,这是源码地址,觉得靠谱的话欢迎加星跟随,有问题欢迎评论和指正😃OK交代完毕，说下这回要完成的内容。这回要做的是一个带缩放功能的滑动菜单(就是一个侧">
<meta name="twitter:image" content="http://leenty.com/img/vue/shangche.jpg">
  
    <link rel="alternative" href="/atom.xml" title="leenty blog" type="application/atom+xml">
  
  
    <link rel="icon" href="//favicon.png">
  
  <script src="/style.js"></script>
  

  
<!-- baidu_tongji -->
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?5bae4c35e53fde3bf2526312c3edaf1d";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<!-- End baidu_tongji -->


</head>
</html>
<body>
  <div id="container">
    <div class="left-col">
      <div class="overlay"></div>
<div class="intrude-less">
	<header id="header" class="inner">
		<a href="/" class="profilepic">
			
			<img src="/img/default_avatar.png" class="js-avatar">
			
		</a>

		<hgroup>
		  <h1 class="header-author"><a href="/">leenty</a></h1>
		</hgroup>

		

		<nav class="header-menu">
			<ul>
			
				<li><a href="/">主页</a></li>
	        
				<li><a href="/archives">所有文章</a></li>
	        
			</ul>
		</nav>
		<nav class="header-smart-menu">
	        
    		
    			
    			<a class="js-smart-menu" data-idx="0" href="javascript:void(0)">所有文章</a>
    			
    			
            
    			
    			<a class="js-smart-menu" data-idx="1" href="javascript:void(0)">标签</a>
    			
    			
            
    			
    			<a class="js-smart-menu" data-idx="2" href="javascript:void(0)">友链</a>
    			
    			
            
    			
    			<a class="js-smart-menu" data-idx="3" href="javascript:void(0)">关于我</a>
    			
    			
            
		</nav>
		<nav class="header-nav">
			<div class="social">
				
					<a class="github" target="_blank" href="https://github.com/leenty" title="github">github</a>
		        
			</div>
		</nav>
	</header>		
</div>

    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
  	<div class="overlay">
  		<div class="slider-trigger"><i class="icon-list"></i></div>
  		<h1 class="header-author js-mobile-header hide">leenty</h1>
  	</div>
	<div class="intrude-less">
		<header id="header" class="inner">
			<div class="profilepic">
				
					<img src="/img/default_avatar.png" class="js-avatar">
				
			</div>
			<hgroup>
			  <h1 class="header-author">leenty</h1>
			</hgroup>
			
			<nav class="header-menu">
				<ul>
				
					<li><a href="/">主页</a></li>
		        
					<li><a href="/archives">所有文章</a></li>
		        
				</ul>
			</nav>
			<nav class="header-nav">
				<div class="social">
					
						<a class="github" target="_blank" href="https://github.com/leenty" title="github">github</a>
			        
				</div>
			</nav>
		</header>				
	</div>
</nav>

      <div class="body-wrap">
        <article id="post-vue2-5" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      vue2.0一起在懵逼的海洋里越陷越深（五）
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h3 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h3><p>本文章系列：<a href="http://leenty.com/tags/vuejs/" target="_blank" rel="noopener">vue2.0一起在懵逼的海洋里越陷越深 (http://leenty.com/tags/vuejs/)</a><br>之前的几篇文章的说了<code>vue-router</code>以及<code>vuex</code>的简单使用，这次就开始组合这两者进行实际应用。<br>场地呢就在我的<a href="http://vue2.leenty.com" target="_blank" rel="noopener">vue2.0Demo</a>,这是<a href="https://github.com/leenty/vue2" target="_blank" rel="noopener">源码地址</a>,觉得靠谱的话欢迎加星跟随,有问题欢迎评论和指正😃<br>OK交代完毕，说下这回要完成的内容。<br>这回要做的是一个带缩放功能的滑动菜单(就是一个侧拉栏)和文章列表，以及文章的展示路由<br>使用<code>vuex</code>做状态管理控制<code>css</code>完成动画过度效果以及使用<code>vue-router</code>的嵌套路由功能。</p>
<p><strong> 滴滴滴！上车请刷卡！</strong><br><img src="http://leenty.com/img/vue/shangche.jpg" alt></p>
<h3 id="正文"><a href="#正文" class="headerlink" title="正文"></a>正文</h3><p>首先，我们先把核心功能完成，也就是<code>vue-router</code>的嵌套路由功能 </p>
<h4 id="嵌套路由功能"><a href="#嵌套路由功能" class="headerlink" title="嵌套路由功能"></a>嵌套路由功能</h4><p>有些时候我们会遇到一个模板重复使用的情况，注意我说的并不是一个子模板在其父模板上的重复，而是多个页面之间的使用到相同的父模板。<br>就好比有这么几个路径</p>
<ul>
<li><code>vue2.leenty.com/article/demo1</code></li>
<li><code>vue2.leenty.com/article/demo2</code></li>
<li><code>vue2.leenty.com/article/demo3</code><br>可以发现其中共有的部分<code>vue2.leenty.com/article</code>。<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">/article/demo1                 /article/demo2               /article/demo3</span><br><span class="line">+------------------+           +-----------------+          +-----------------+</span><br><span class="line">| article          |           | article         |          | article         |</span><br><span class="line">| +--------------+ |           | +-------------+ |          | +-------------+ |</span><br><span class="line">| | demo1        | |  +-----&gt;  | | demo2       | | +-----&gt;  | | demo3       | |</span><br><span class="line">| |              | |           | |             | |          | |             | |</span><br><span class="line">| +--------------+ |           | +-------------+ |          | +-------------+ |</span><br><span class="line">+------------------+           +-----------------+          +-----------------+</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>没错，这个路径指向的就是父模板，他在多个子路由里被重复的渲染，如果我们没有对其做嵌套路由的处理，结果将是不仅我们写的累，vuejs渲染的也多余，因为这个模板被反复的使用却每次都被重新渲染。<br>so，我们开始做嵌套路由吧！<br>打开路由列表文件(<code>routes.js</code>)<br>tips:不要把<code>routes.js</code>和项目里的<code>router.js</code>搞混咯，一个是路由列表文件<code>routes.js</code>，一个是路由导出文件<code>router.js</code><br>在里面我们假定有一个基础的路由（这个文件在本系列第二章里有讲到）<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> routes = [</span><br><span class="line">  &#123;</span><br><span class="line">    name: <span class="string">'Article'</span>,</span><br><span class="line">    path: <span class="string">'/article'</span>,</span><br><span class="line">    component: <span class="built_in">require</span>(<span class="string">'./components/Article.vue'</span>)</span><br><span class="line">    <span class="comment">// 这里因为书写以及以后做异步组件的方便，将原先的import导入的方式改成了require的方式</span></span><br><span class="line">    <span class="comment">// 这么做不会实质上没和之前没有变化的，只是单纯的写法不同。</span></span><br><span class="line">  &#125;</span><br><span class="line">]</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> routes</span><br></pre></td></tr></table></figure></p>
<p>好，接下来我们加入子路由，<br>目前本系列已经有五篇文章，那么现在一一加入进去。<br>当前的项目路径<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">src</span><br><span class="line">├── main.js               # vuejs应用入口</span><br><span class="line">├── router.js             # 路由导出文件</span><br><span class="line">├── routes.js             # 路由列表文件</span><br><span class="line">├── App.vue               # vuejs应用根模板</span><br><span class="line">├── components</span><br><span class="line">│   ├── Home.vue</span><br><span class="line">│   ├── Article.vue</span><br><span class="line">│   ├── Demo.vue</span><br><span class="line">│   ├── ...               # 存放各个路由入口文件</span><br><span class="line">│   └── templates         # 存放模板</span><br><span class="line">│       ├── AppArticleList.vue    # 文章列表 </span><br><span class="line">│       └── ...</span><br><span class="line">└── store</span><br><span class="line">│   ├── index.js          # 组装模块并导出 store 的地方</span><br><span class="line">│   ├── actions.js        # 根级别的 action</span><br><span class="line">│   ├── mutations.js      # 根级别的 mutation</span><br><span class="line">│   ├── types.js          # mutation命名空间</span><br><span class="line">│   └── modules</span><br><span class="line">│       ├── demo.js       # demo模块</span><br><span class="line">│       └── status.js     # 全局应用状态模块</span><br><span class="line">└── md                    # 存放md文件</span><br><span class="line">    └── articles          # 文章路径 </span><br><span class="line">        ├── vue2-1.vue</span><br><span class="line">        ├── vue2-2.vue</span><br><span class="line">        ├── vue2-3.vue</span><br><span class="line">        ├── vue2-4.vue</span><br><span class="line">        └── vue2-5.vue</span><br><span class="line">        (这里为了讲解方便，会将.md文件替换为.vue文件，)</span><br><span class="line">        (效果是一样的只是怕读者有些乱，.vue文件你们尝试的时候可以写些东西)</span><br></pre></td></tr></table></figure></p>
<p>嵌套路由时会在原有路由对象的基础上添加一个<code>children</code>的节点<br>代码如下：<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> routes = [</span><br><span class="line">  &#123;</span><br><span class="line">    name: <span class="string">'Article'</span>,</span><br><span class="line">    path: <span class="string">'/article'</span>,</span><br><span class="line">    <span class="comment">// 父路由上尽量写绝对路径，不然可能会引起一些麻烦，</span></span><br><span class="line">    <span class="comment">// 有捣(xia)鼓(gao)精神的同学可以试试</span></span><br><span class="line">    component: <span class="built_in">require</span>(<span class="string">'./components/Article.vue'</span>),</span><br><span class="line">    children: [</span><br><span class="line">    <span class="comment">// children节点：传入一个子路由数组，格式与父路由是一样的</span></span><br><span class="line">      &#123;</span><br><span class="line">        name: <span class="string">'vue2_1'</span>,</span><br><span class="line">        path: <span class="string">'vue2_1'</span>,</span><br><span class="line">        <span class="comment">// path: 导入的路径是相对路径，你不需要写全，如下的path将会被vuejs理解为：</span></span><br><span class="line">        <span class="comment">// '/article/vue2_1'</span></span><br><span class="line">        <span class="comment">// *** 注意： ***</span></span><br><span class="line">          <span class="comment">// 如果你写的是这样的相对路径，就千万别在前面加'/'，不然就意味着这是一个绝对路径</span></span><br><span class="line">        component: <span class="built_in">require</span>(<span class="string">'./md/articles/vue2-1.vue'</span>)</span><br><span class="line">      &#125;,</span><br><span class="line">      &#123;</span><br><span class="line">        name: <span class="string">'vue2_2'</span>,</span><br><span class="line">        path: <span class="string">'/article/vue2_2'</span>,</span><br><span class="line">        <span class="comment">// 演示一个绝对路径，这样子的路径会被vuejs理解为其本意'/article/vue2_2'</span></span><br><span class="line">        <span class="comment">// 如果这里只写了'/vue2_2'的话，vuejs就会把路由理解为'/vue2_2'，</span></span><br><span class="line">        <span class="comment">// 不过不用担心他显示上的问题，只是url会有些有趣的区别</span></span><br><span class="line">        <span class="comment">// 你会发现虽然url变短了，但是父模板依然正常的显示着。</span></span><br><span class="line">        component: <span class="built_in">require</span>(<span class="string">'./md/articles/vue2-2.vue'</span>)</span><br><span class="line">      &#125;,</span><br><span class="line">      &#123;</span><br><span class="line">        name: <span class="string">'vue2_3'</span>,</span><br><span class="line">        path: <span class="string">'vue2_3'</span>,</span><br><span class="line">        component: <span class="built_in">require</span>(<span class="string">'./md/articles/vue2-3.vue'</span>)</span><br><span class="line">      &#125;,</span><br><span class="line">      &#123;</span><br><span class="line">        name: <span class="string">'vue2_4'</span>,</span><br><span class="line">        path: <span class="string">'vue2_4'</span>,</span><br><span class="line">        component: <span class="built_in">require</span>(<span class="string">'./md/articles/vue2-4.vue'</span>)</span><br><span class="line">      &#125;,</span><br><span class="line">      &#123;</span><br><span class="line">        name: <span class="string">'vue2_5'</span>,</span><br><span class="line">        path: <span class="string">'vue2_5'</span>,</span><br><span class="line">        component: <span class="built_in">require</span>(<span class="string">'./md/articles/vue2-5.vue'</span>)</span><br><span class="line">      &#125;</span><br><span class="line">    ]</span><br><span class="line">  &#125;</span><br><span class="line">]</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> routes</span><br></pre></td></tr></table></figure></p>
<p>嗯，好了，这样嵌套路由就建立好了</p>
<h4 id="对侧拉栏做状态管理"><a href="#对侧拉栏做状态管理" class="headerlink" title="对侧拉栏做状态管理"></a>对侧拉栏做状态管理</h4><p>打开<code>src/store/modules/status.js</code><br>代码如下<br><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> * <span class="keyword">as</span> types <span class="keyword">from</span> <span class="string">'../types'</span></span><br><span class="line"><span class="comment">// 引入命名空间，放置在types里</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> getScrollData <span class="keyword">from</span> <span class="string">'../../utils/scroll'</span></span><br><span class="line"><span class="comment">// 这是获得滚动数据的js文件，具体怎样写的可以去我github开源项目里看</span></span><br><span class="line"><span class="comment">// 导出的是一个方法，这个方法返回一个对象</span></span><br><span class="line"><span class="comment">// &#123;</span></span><br><span class="line"><span class="comment">//    scrollTop: 0,</span></span><br><span class="line"><span class="comment">//    scrollHeight: 0,</span></span><br><span class="line"><span class="comment">//    windowHeight: 0,</span></span><br><span class="line"><span class="comment">//    scrollBottom: 0</span></span><br><span class="line"><span class="comment">// &#125;</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> state = &#123;</span><br><span class="line">  articleList: <span class="literal">false</span>,</span><br><span class="line">  <span class="comment">// 布尔值，表示侧拉文章列表的开关</span></span><br><span class="line">  scroll: &#123;</span><br><span class="line">  <span class="comment">// 滚动相关的数据</span></span><br><span class="line">    scrollTop: <span class="number">0</span>,</span><br><span class="line">    scrollHeight: <span class="number">0</span>,</span><br><span class="line">    windowHeight: <span class="number">0</span>,</span><br><span class="line">    scrollBottom: <span class="number">0</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> getters = &#123;</span><br><span class="line">  <span class="comment">// articleList: (&#123;status&#125;) =&gt; status.articleList</span></span><br><span class="line">  <span class="comment">// tips: 上面这种方法是错误的。这里的getters传入进来的不是state的根对象，</span></span><br><span class="line">  <span class="comment">// 而是当前的state对象，在这里也就相当于是state = state.status</span></span><br><span class="line">  <span class="comment">// 所以可以放心的用state</span></span><br><span class="line">  articleList: <span class="function"><span class="params">state</span> =&gt;</span> state.articleList</span><br><span class="line">  <span class="comment">// 设置Getters，在.vue文件里可以使用mapGetters方法获得</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> mutations = &#123;</span><br><span class="line">  [types.ARTICLE_LIST] (state) &#123;</span><br><span class="line">    state.articleList = !state.articleList</span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="comment">// 设置mutations，只有这个方法可以改变state</span></span><br><span class="line">  [types.SCROLLDATA] (state, scrollObj) &#123;</span><br><span class="line">    state.scroll = scrollObj</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> actions = &#123;</span><br><span class="line">  articleListSwitch (&#123; commit &#125;) &#123;</span><br><span class="line">    commit(types.ARTICLE_LIST)</span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="comment">// 设置actions,可以在这里做一些异步的工作，然后使用commit来调用mutations修改state</span></span><br><span class="line">  pushScrollData (&#123; commit &#125;) &#123;</span><br><span class="line">    commit(types.SCROLLDATA, getScrollData(), &#123; <span class="attr">silent</span>: <span class="literal">true</span> &#125;)</span><br><span class="line">    <span class="comment">// 因为页面滚动触发频繁，会影响到我们平时的vuex的审查，所以这里选择静默提交</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">export</span> <span class="keyword">default</span> &#123;</span><br><span class="line">  state,</span><br><span class="line">  getters,</span><br><span class="line">  actions,</span><br><span class="line">  mutations</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 而后的.vue文件就可以调用辅助方法达到获取状态或者控制状态的目的了</span></span><br></pre></td></tr></table></figure></p>
<p>调试vuex最好使用vuejs的谷歌插件<a href="https://chrome.google.com/webstore/detail/nhdogjmejiglipccpnnnanhbledajbpd" target="_blank" rel="noopener">Devtools</a><br>或者去github<a href="https://github.com/vuejs/vue-devtools" target="_blank" rel="noopener">下载源码自己编译</a><br>翻墙要梯子(vpn)，想翻墙没vpn的我这里安利一个vpn，没什么其他，因为我正用的就是这个。<br>贴一个云梯推荐码<a href="http://referyt.com/?r=f688f08a26bf108d" target="_blank" rel="noopener">http://referyt.com/?r=f688f08a26bf108d</a>,通过推荐码注册可以优惠10元，笔者也可以得到10元优惠，在得到优惠的同时也是对我的鼓舞吧😂</p>
<h4 id="渲染链接列表"><a href="#渲染链接列表" class="headerlink" title="渲染链接列表"></a>渲染链接列表</h4><p>接下来要做的就是做链接跳转。<br>切到<code>AppArticleList.vue</code>文件，也就是文章列表页。<br>大家可以在我的Demo里点击左上角的菜单按钮看到这个列表<br>!(AppArticleList.vue)[/img/vue/AppArticleList.jpg]</p>
<p>里面的内容是这样子的<br>(因为内容有些复杂，为了看的清晰点这是我提取出来的核心部分)<br>(源文件可以看<a href="https://github.com/leenty/vue2/blob/master/src/components/templates/AppArticleList.vue" target="_blank" rel="noopener">https://github.com/leenty/vue2/blob/master/src/components/templates/AppArticleList.vue</a>)<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 大致的内容就是渲染一个文章列表 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">template</span> <span class="attr">lang</span>=<span class="string">"pug"</span>&gt;</span></span><br><span class="line">  .articleList(:class="&#123;'articleList--Active': articleList&#125;").l-page--Full</span><br><span class="line">    ul.articleList__content.u-ul--Reset</span><br><span class="line">      li(</span><br><span class="line">        v-for="(item, index) in list",</span><br><span class="line">        // vuejs的for循环，list指向了data里的list数组(看js部分)</span><br><span class="line">        :style="calcDelay(index)",</span><br><span class="line">        // 绑定返回一个css延时代码(在methods方法下)</span><br><span class="line">        // 主要功能是给菜单提供依次进入的动画效果</span><br><span class="line">        @click="articleListSwitch"</span><br><span class="line">        // 绑定点击事件，控制文章列表的出现和隐藏</span><br><span class="line">      ).articleList__li</span><br><span class="line">        router-link(</span><br><span class="line">        // 通过list里的数据循环生成路由链接</span><br><span class="line">          :to="&#123;name: item.name&#125;",</span><br><span class="line">          // 绑定路由链接，这里用了&#123;name: item.name&#125;是因为相对来说，name比path方便</span><br><span class="line">          // item就是之前for循环里的item</span><br><span class="line">          active-class="articleList__link--Active"</span><br><span class="line">          // 之前的文章的第二篇里对路由时匹配的`linkActiveClass`做了配置，</span><br><span class="line">          // 这里用不到原来配置的class,所以可以用这个方法单独的做处理</span><br><span class="line">          // 把匹配到的链接的class改成了'articleList__link--Active'</span><br><span class="line">        ).articleList__link.u-borderBox.u-link__inherit.l-flexV--c</span><br><span class="line">          .articleList__title</span><br><span class="line">            svg.svg__home.u-va--tb</span><br><span class="line">              use(xlink:href="#svg__articleIcon")</span><br><span class="line">            // 这里用的图标是svg的,关于这种用法，如果有兴趣我可以专门的介绍一下</span><br><span class="line">            | &#123;&#123;item.title&#125;&#125; </span><br><span class="line">            // 绑定链接的文字</span><br><span class="line"><span class="tag">&lt;/<span class="name">template</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="javascript"><span class="keyword">import</span> &#123; mapActions, mapGetters &#125; <span class="keyword">from</span> <span class="string">'vuex'</span></span></span><br><span class="line"><span class="javascript"><span class="comment">// 导入vuex的两个将要用到的辅助方法</span></span></span><br><span class="line"><span class="javascript"><span class="keyword">export</span> <span class="keyword">default</span> &#123;</span></span><br><span class="line"><span class="javascript">  <span class="comment">// export defalut是es6的模块导出方法，这里导出一个默认模块，即是一个vue对象</span></span></span><br><span class="line">  data () &#123;</span><br><span class="line"><span class="javascript">    <span class="comment">// 这是一种es6对象字面量的缩写，指向一个函数</span></span></span><br><span class="line"><span class="javascript">    <span class="comment">// 扩展出来就是data: function data () &#123;&#125;</span></span></span><br><span class="line"><span class="javascript">    <span class="keyword">return</span> &#123;</span></span><br><span class="line"><span class="javascript">      <span class="comment">// 而后在函数里去返回将要用到的数据</span></span></span><br><span class="line"><span class="javascript">      <span class="comment">// 这么做返回的数据可以使用this访问到</span></span></span><br><span class="line">      list: [</span><br><span class="line">        &#123;</span><br><span class="line"><span class="javascript">          name: <span class="string">'vue2_1'</span>,</span></span><br><span class="line"><span class="javascript">          title: <span class="string">'vue2.0一起在懵逼的海洋里越陷越深（一）'</span></span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line"><span class="javascript">          name: <span class="string">'vue2_2'</span>,</span></span><br><span class="line"><span class="javascript">          title: <span class="string">'vue2.0一起在懵逼的海洋里越陷越深（二）'</span></span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line"><span class="javascript">          name: <span class="string">'vue2_3'</span>,</span></span><br><span class="line"><span class="javascript">          title: <span class="string">'vue2.0一起在懵逼的海洋里越陷越深（三）'</span></span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line"><span class="javascript">          name: <span class="string">'vue2_4'</span>,</span></span><br><span class="line"><span class="javascript">          title: <span class="string">'vue2.0一起在懵逼的海洋里越陷越深（四）'</span></span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line"><span class="javascript">          name: <span class="string">'vue2_5'</span>,</span></span><br><span class="line"><span class="javascript">          title: <span class="string">'vue2.0一起在懵逼的海洋里越陷越深（五）'</span></span></span><br><span class="line">        &#125;</span><br><span class="line">      ]</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;,</span><br><span class="line"><span class="javascript">  computed: mapGetters([<span class="string">'articleList'</span>]),</span></span><br><span class="line"><span class="javascript">  <span class="comment">// vue的计算方法对象,用法和data里的数据是一样的，</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">// 这里使用了mapGetters辅助函数，用来获得vuex的Getters里的articleList</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">// 这个方法会返回一个对象，所以如果没有其他计算方法的话直接赋值给computed就好了</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">// 有的话可以向下面这样: </span></span></span><br><span class="line"><span class="javascript">  <span class="comment">// computed: &#123;</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">//    demo () &#123;</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">//      return this.list[0].name</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">//      在这里你可以使用this访问到data里的list</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">//    &#125;,</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">//    ...mapGetters(['articleList'])</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">//    ...延展操作符，用于展开mapGetters得到的对象，使得与demo属性平级</span></span></span><br><span class="line"><span class="javascript">  <span class="comment">// &#125;,</span></span></span><br><span class="line">  methods: &#123;</span><br><span class="line"><span class="javascript">    <span class="comment">// vue的方法对象，你可以在这里写你的事件处理函数或是其他方法</span></span></span><br><span class="line"><span class="javascript">    calcDelay: <span class="function"><span class="keyword">function</span> (<span class="params">index</span>) </span>&#123;</span></span><br><span class="line"><span class="javascript">      <span class="comment">// 这是分配css动画延迟量的函数</span></span></span><br><span class="line"><span class="javascript">      <span class="keyword">return</span> &#123;</span></span><br><span class="line"><span class="javascript">        <span class="string">'transitionDelay'</span>: <span class="string">`.<span class="subst">$&#123;index + <span class="number">2</span>&#125;</span>s`</span></span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;,</span><br><span class="line"><span class="javascript">    ...mapActions([<span class="string">'articleListSwitch'</span>])</span></span><br><span class="line"><span class="javascript">    <span class="comment">// 通过延展操作符,展开mapActions得到的actions对象</span></span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">style</span> <span class="attr">lang</span>=<span class="string">"stylus"</span>&gt;</span></span><br><span class="line">  // css就不多说了</span><br><span class="line"><span class="css">  @<span class="keyword">import</span> <span class="string">'../../assets/stylus/preinstall'</span></span></span><br><span class="line"><span class="css">  <span class="selector-class">.articleList</span></span></span><br><span class="line">    background-color c-master</span><br><span class="line"><span class="css">  <span class="selector-class">.articleList__content</span></span></span><br><span class="line">    width s-articleList</span><br><span class="line">    margin-top 8vh</span><br><span class="line">    max-height 84vh</span><br><span class="line"><span class="css">    <span class="selector-tag">color</span> <span class="selector-id">#fff</span></span></span><br><span class="line"><span class="css">  <span class="selector-class">.articleList__li</span></span></span><br><span class="line">    transform translateX(-(s-articleList))</span><br><span class="line"><span class="css">    <span class="selector-tag">transition</span> <span class="selector-tag">transform</span> <span class="selector-class">.3s</span> <span class="selector-tag">cb-duang</span> <span class="selector-class">.2s</span></span></span><br><span class="line"><span class="css">  <span class="selector-class">.articleList__link</span></span></span><br><span class="line">    width 100%</span><br><span class="line"><span class="css">    <span class="selector-tag">line-height</span> 1<span class="selector-class">.3em</span></span></span><br><span class="line">    padding-left 10px</span><br><span class="line">    min-height 50px</span><br><span class="line"><span class="css">    <span class="selector-tag">background-color</span> <span class="selector-tag">rgba</span>(255,255,255,<span class="selector-class">.1</span>)</span></span><br><span class="line"><span class="css">    &amp;<span class="selector-pseudo">:hover</span></span></span><br><span class="line"><span class="css">      <span class="selector-tag">background-color</span> <span class="selector-tag">rgba</span>(255,255,255,<span class="selector-class">.3</span>)</span></span><br><span class="line">    svg</span><br><span class="line">      transform-origin bottom center</span><br><span class="line"><span class="css">      <span class="selector-tag">transform</span> <span class="selector-tag">scale</span>(<span class="selector-class">.7</span>)</span></span><br><span class="line"><span class="css">  <span class="selector-class">.articleList__link--Active</span></span></span><br><span class="line"><span class="css">    <span class="selector-tag">background-color</span> <span class="selector-tag">rgba</span>(255,255,255,<span class="selector-class">.4</span>)</span></span><br><span class="line"><span class="css">  <span class="selector-class">.articleList--Active</span> <span class="selector-class">.articleList__li</span></span></span><br><span class="line">    transform translateX(0)</span><br><span class="line"><span class="css">  <span class="selector-class">.articleList__title</span></span></span><br><span class="line">    display block</span><br><span class="line">    width 100%</span><br><span class="line">    font-size 12px</span><br><span class="line"><span class="css">    &amp;<span class="selector-pseudo">:first-line</span></span></span><br><span class="line">      font-size 14px</span><br><span class="line"><span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<p>在写的过程中碰到了一个浏览器bug，这里还是说下<br>bug: 如果父元素进行了transform变换，那么子元素的position fixed将会失去作用,退化成position absolute<br>解决方案: 之前试过想要使用css的方式去绕过这个问题，但是发现不行，无奈使用了js去计算子元素退化成absolute后的差值，对其进行位移达到视觉的效果。<br>有兴趣的可以打开<a href="http://vue2.leenty.com/article/vue2_2" target="_blank" rel="noopener">http://vue2.leenty.com/article/vue2_2</a>然后审查元素，查看我的导航条也就是<code>.header__content</code>，这个时候你打开侧边栏然后上下滚动就会看到<code>.header__content</code>上js所不全的差值了</p>
<h4 id="装载嵌套路由"><a href="#装载嵌套路由" class="headerlink" title="装载嵌套路由"></a>装载嵌套路由</h4><p>打开<code>article.vue</code>文件，文件很简单，内容如下：<br><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">template</span> <span class="attr">lang</span>=<span class="string">"pug"</span>&gt;</span></span><br><span class="line">.article</span><br><span class="line">  h1.l-ta--c 文章页面</span><br><span class="line">  .md-content</span><br><span class="line">    router-view</span><br><span class="line">    // 这个就是二级路由的装载点了</span><br><span class="line">    // 之前的`APP.vue`的`router-view`会装载当前模板，而后的文章都会装载到这个点上。</span><br><span class="line"><span class="tag">&lt;/<span class="name">template</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="javascript">  <span class="keyword">export</span> <span class="keyword">default</span> &#123;</span></span><br><span class="line">    data () &#123;</span><br><span class="line"><span class="javascript">      <span class="keyword">return</span> &#123;</span></span><br><span class="line">      &#125;</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">style</span> <span class="attr">lang</span>=<span class="string">"stylus"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br></pre></td></tr></table></figure></p>
<h4 id="关于触发滚动之后的一系列事件"><a href="#关于触发滚动之后的一系列事件" class="headerlink" title="关于触发滚动之后的一系列事件"></a>关于触发滚动之后的一系列事件</h4><p>关于触发滚动，考虑到之后可能会有多个页面需要使滚动方面的数据，所以就放在了vuex里作为状态的一部分。<br>所以滚动的监听就只需要监听一次就好了，多个地方的监听会浪费资源<br>最终，我把监听放在了<code>App.vue</code>里面,在里面监听’scroll’事件，然后放在vuex上，供有需要的组件去使用</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">template</span> <span class="attr">lang</span>=<span class="string">"pug"</span>&gt;</span></span><br><span class="line">  .app.u-clearfix</span><br><span class="line">    app-article-list</span><br><span class="line">    .app__content(</span><br><span class="line">      :class="&#123;'app__content--Active': articleList&#125;",</span><br><span class="line">      // 如果侧拉文章列表打开，那么添加这个class，相应的css效果将被触发</span><br><span class="line">      @scroll="pushScrollData"</span><br><span class="line">      // 绑定scroll事件</span><br><span class="line">    ).l-page--Full</span><br><span class="line">      home-header</span><br><span class="line">      .app__bodyer.l-mH--auto</span><br><span class="line">        router-view</span><br><span class="line">    include ./assets/svg/all</span><br><span class="line"><span class="tag">&lt;/<span class="name">template</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span></span><br><span class="line"><span class="javascript">  <span class="keyword">import</span> HomeHeader <span class="keyword">from</span> <span class="string">'./components/templates/HomeHeader.vue'</span></span></span><br><span class="line"><span class="javascript">  <span class="keyword">import</span> AppArticleList <span class="keyword">from</span> <span class="string">'./components/templates/AppArticleList.vue'</span></span></span><br><span class="line"><span class="javascript">  <span class="keyword">import</span> &#123; mapGetters, mapActions &#125; <span class="keyword">from</span> <span class="string">'vuex'</span></span></span><br><span class="line"><span class="javascript">  <span class="keyword">export</span> <span class="keyword">default</span> &#123;</span></span><br><span class="line">    components: &#123;</span><br><span class="line">      HomeHeader,</span><br><span class="line">      AppArticleList</span><br><span class="line">    &#125;,</span><br><span class="line">    computed: mapGetters([</span><br><span class="line"><span class="javascript">      <span class="string">'articleList'</span></span></span><br><span class="line">    ]),</span><br><span class="line">    methods: &#123;</span><br><span class="line">      ...mapActions([</span><br><span class="line"><span class="javascript">        <span class="string">'pushScrollData'</span>,</span></span><br><span class="line"><span class="javascript">        <span class="string">'articleListSwitch'</span></span></span><br><span class="line">      ])</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">style</span> <span class="attr">lang</span>=<span class="string">"stylus"</span>&gt;</span></span><br><span class="line"><span class="css">  @<span class="keyword">import</span> <span class="string">'./assets/stylus/main'</span></span></span><br><span class="line"><span class="css">  <span class="selector-class">.app__menu</span></span></span><br><span class="line">    background-color c-master</span><br><span class="line"><span class="css">  <span class="selector-class">.app__content</span></span></span><br><span class="line">    overflow auto</span><br><span class="line"><span class="css">    <span class="selector-tag">transition</span> <span class="selector-tag">transform</span> <span class="selector-class">.5s</span></span></span><br><span class="line"><span class="css">    <span class="selector-tag">box-shadow</span> 0 0 100<span class="selector-tag">px</span> 5<span class="selector-tag">px</span> <span class="selector-tag">rgba</span>(0,0,0,0<span class="selector-class">.3</span>)</span></span><br><span class="line">    background-color c-bgc</span><br><span class="line">    transform-origin s-articleList center</span><br><span class="line"><span class="css">  <span class="selector-class">.app__content--Active</span></span></span><br><span class="line"><span class="css">    <span class="selector-tag">transform</span> <span class="selector-tag">scale</span>(<span class="selector-class">.9</span>) <span class="selector-tag">translateX</span>(<span class="selector-tag">s-articleList</span>)</span></span><br><span class="line"><span class="css">  <span class="selector-class">.app__bodyer</span></span></span><br><span class="line">    max-width max-width</span><br><span class="line">    background-color c-bgc</span><br><span class="line"><span class="css">  @<span class="keyword">media</span> screen and (max-width: max-width)</span></span><br><span class="line"><span class="css">    <span class="selector-class">.app__bodyer</span></span></span><br><span class="line">      padding 0 10px</span><br><span class="line"><span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>ok，这么个流程走下来，算是把<code>vuejs</code>,<code>vue-router</code>和<code>vuex</code>用在了一起</p>
<h3 id="其他"><a href="#其他" class="headerlink" title="其他"></a>其他</h3><p><a href="http://vue2.leenty.com" target="_blank" rel="noopener">演示地址(http://vue2.leenty.com)</a><br><a href="https://github.com/leenty/vue2" target="_blank" rel="noopener">源码地址(https://github.com/leenty/vue2)</a><br><a href="https://github.com/leenty" target="_blank" rel="noopener">github主页</a>,觉得靠谱的话欢迎加星跟随</p>

      
    </div>
    <div class="article-info article-info-index">
      
      <a href="/2016/12/11/vue2-5/" class="archive-article-date">
  	<time datetime="2016-12-11T14:20:04.000Z" itemprop="datePublished"><i class="icon-clock"></i>2016-12-11</time>
</a>
      
	<div class="article-tag tagcloud">
		<i class="icon-price-tags"></i>
		<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/css/">css</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vue-router/">vue-router</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vuejs/">vuejs</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/vuex/">vuex</a></li></ul>
	</div>

      

      <div class="clearfix"></div>
    </div>
  </div>
</article>

  
<nav id="article-nav">
  
    <a href="/2016/12/18/vue2-6/" id="article-nav-newer" class="article-nav-link-wrap">
      <i class="icon-circle-left"></i>
      <div class="article-nav-title">
        
          vue2.0一起在懵逼的海洋里越陷越深（六）
        
      </div>
    </a>
  
  
    <a href="/2016/12/04/vue2-4/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">vue2.0一起在懵逼的海洋里越陷越深（四）</div>
      <i class="icon-circle-right"></i>
    </a>
  
</nav>




<div class="share_jia">
	<!-- JiaThis Button BEGIN -->
	<div class="jiathis_style">
		<span class="jiathis_txt">Share to: &nbsp; </span>
		<a class="jiathis_button_facebook"></a> 
	    <a class="jiathis_button_twitter"></a>
	    <a class="jiathis_button_plus"></a> 
	    <a class="jiathis_button_tsina"></a>
		<a class="jiathis_button_cqq"></a>
		<a class="jiathis_button_douban"></a>
		<a class="jiathis_button_weixin"></a>
		<a class="jiathis_button_tumblr"></a>
    <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
	</div>
	<script type="text/javascript" src="//v3.jiathis.com/code/jia.js?uid=1405949716054953" charset="utf-8"></script>
	<!-- JiaThis Button END -->
</div>






<div class="duoshuo">
	<!-- 多说评论框 start -->
	<div class="ds-thread" data-thread-key="vue2-5" data-title="vue2.0一起在懵逼的海洋里越陷越深（五）" data-url="http://baidu.com/2016/12/11/vue2-5/"></div>
	<!-- 多说评论框 end -->
	<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
	<script type="text/javascript">
	var duoshuoQuery = {short_name:"leenty-blog"};
	(function() {
		var ds = document.createElement('script');
		ds.type = 'text/javascript';ds.async = true;
		ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
		ds.charset = 'UTF-8';
		(document.getElementsByTagName('head')[0] 
		 || document.getElementsByTagName('body')[0]).appendChild(ds);
	})();
	</script>
	<!-- 多说公共JS代码 end -->
</div>





      </div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info">
    	<div class="footer-left">
    		&copy; 2019 leenty
    	</div>
      	<div class="footer-right">
      		<a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/litten/hexo-theme-yilia" target="_blank">Yilia</a> by Litten
      	</div>
    </div>
  </div>
</footer>
    </div>
    <script>
	var yiliaConfig = {
		fancybox: true,
		mathjax: false,
		animate: true,
		isHome: false,
		isPost: true,
		isArchive: false,
		isTag: false,
		isCategory: false,
		open_in_new: false,
		root: "/",
		innerArchive: true
	}
</script>

<script src="/./main.js"></script>


    
<div class="tools-col">
  <ul class="btn-wrap">
    
      <li class="chose" data-hook="tools-section-all"><span class="text">全部</span><i class="icon-book"></i></li>
    
    
      <li data-hook="tools-section-tag"><span class="text">标签</span><i class="icon-price-tags"></i></li>
    
    
      <li data-hook="tools-section-friends"><span class="text">友链</span><i class="icon-link"></i></li>
    
    
      <li data-hook="tools-section-me"><span class="text">我</span><i class="icon-smile"></i></li>
    
  </ul>
  <div class="tools-wrap">
    
    	<section class="tools-section tools-section-all chose">
    	</section>
    

    
    	<section class="tools-section tools-section-tag">
    			<div class="widget tagcloud" id="js-tagcloud">
    				<a href="/tags/ES6/" style="font-size: 10px;">ES6</a> <a href="/tags/css/" style="font-size: 15px;">css</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/github/" style="font-size: 10px;">github</a> <a href="/tags/gulp/" style="font-size: 10px;">gulp</a> <a href="/tags/hexo/" style="font-size: 12.5px;">hexo</a> <a href="/tags/js/" style="font-size: 12.5px;">js</a> <a href="/tags/other/" style="font-size: 10px;">other</a> <a href="/tags/sublime/" style="font-size: 10px;">sublime</a> <a href="/tags/vim/" style="font-size: 10px;">vim</a> <a href="/tags/vue-router/" style="font-size: 17.5px;">vue-router</a> <a href="/tags/vuejs/" style="font-size: 20px;">vuejs</a> <a href="/tags/vuex/" style="font-size: 12.5px;">vuex</a>
    			</div>
    	</section>
    

    
    	<section class="tools-section tools-section-friends">
  		
  			<div class="friends-wrap" id="js-friends">
  			
  	          <a target="_blank" class="main-nav-link switch-friends-link" href="http://vue2.leenty.com">vue2.0演示地址</a>
  	        
  	          <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.leenty.com/">leenty的博客</a>
  	        
  	          <a target="_blank" class="main-nav-link switch-friends-link" href="https://whqet.github.io/">whqet的博客</a>
  	        
  	          <a target="_blank" class="main-nav-link switch-friends-link" href="https://shenyubin.github.io/">沈雨彬的博客</a>
  	        
  	          <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.deboy.cn">Deboy的博客</a>
  	        
  	        </div>
  		
    	</section>
    

    
    	<section class="tools-section tools-section-me">
  	  	
  	  		<div class="aboutme-wrap" id="js-aboutme">不会捣(xia)鼓(gao)的前端不是好全栈</div>
  	  	
    	</section>
    
  </div>
  
</div>
    <!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                      <div class="pswp__preloader__cut">
                        <div class="pswp__preloader__donut"></div>
                      </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div> 
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>
  </div>
</body>
</html>